<template>
  <div>
    <!-- 轮播图 -->
    <div class="swiper">
      <van-swipe class="my-swipe" :autoplay="4000" indicator-color="white">
        <van-swipe-item v-for="(swiper, index) in focusList" :key="index">
          <img class="swiperImg" :src="swiper.picUrl" alt="" />
        </van-swipe-item>
      </van-swipe>
    </div>

    <!-- 四季款 -->
    <div class="itemFloor" v-for="(item, index) in categoryList" :key="index">
      <div class="floor">
        <span class="floor1" v-if="item.category?.frontName">{{
          item.category.frontName ? item.category.frontName : item.category.name
        }}</span>
        <span class="floor2" v-if="item.category?.frontDesc">{{ item.category.frontDesc }}</span>
      </div>
      <div class="floors">
        <!-- 图片 到手价 -->
        <div class="floorList" v-for="(floor, index) in item.itemList" :key="index">
          <div class="floorListTop">
            <span class="floorListTop1" v-if="floor.colorNum">{{ floor.colorNum }}色可选</span>
            <img class="floorListTop2" :src="floor.listPicUrl" alt="" />
          </div>
          <div class="floorListCenter">
            <img
              class="floorListCenterImg"
              src="https://yanxuan.nosdn.127.net/static-union/16698631101bcf18.png"
              alt=""
            />
            <span class="floorListCenterTexte">{{ floor.name }}</span>
          </div>
          <div class="money">
            <img
              class="moneyImg"
              src="https://yanxuan.nosdn.127.net/static-union/166909947513c0c8.png"
              alt=""
            />
            <span class="moneyText">可用红包</span>
          </div>
          <div class="hand">
            <span class="hand1">到手￥</span>
            <span class="hand2">{{ floor.retailPrice }}</span>
            <span class="hand3">{{ floor.sortOriginPrice }}</span>
          </div>
          <div class="floorListFoot">满99减20元</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'Storey'
})
</script>
<script lang="ts" setup>
import { useChannelStore } from '@/stores/channel'
import { onMounted, ref, watch } from 'vue'
import { storeToRefs } from 'pinia'
import { useHomeStore } from '@/stores/home'
const store = useHomeStore()
const store1 = useChannelStore()
const prop = defineProps<{ categoryList: any }>()

const { focusList } = storeToRefs(store)
// 在首页发送请求
// onMounted(() => {
//   store1.getChannel(1010000)
// })

// watch(
//   () => prop.currentId,
//   () => {
//     store1.getChannel(prop.currentId)
//   },
//   {
//     immediate: true
//   }
// )
// watch(
//   prop.currentId,
//   (newValue: number) => {
//     store1.getChannel(newValue)
//   },
//   { immediate: true }
// )
const { swiperList, categoryList } = storeToRefs(store1)
</script>

<style lang="less" scoped>
.swiper {
  height: 158px;
  background-color: #eeeeee;
  margin: 16px 0 10px;
  :deep(.van-swipe__indicator) {
    width: 25px;
    height: 2px;
    border-radius: 0;
  }
  .swiperImg {
    width: 375px;
    height: 148px;
  }
}

.itemFloor {
  padding: 0 10px;
  height: calc(100% - 225px);
  .floor {
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    .floor1 {
      font-size: 16px;
      margin-top: 14px;
    }
    .floor2 {
      margin-top: 10px;
      font-size: 12px;
      color: #999999;
    }
  }
  .floors {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .floorList {
      margin-top: 10px;
      background-color: #ededed;
      border-radius: 10px;
      width: 172px;
      height: 300px;
      .floorListTop {
        width: 172px;
        height: 172;
        display: flex;
        position: relative;

        .floorListTop1 {
          margin: 5px;
          width: 8px;
          height: 63px;
          font-size: 12px;
          padding: 2px 8px;
          background-color: #f4f4f4;
          color: #b4a08b;
          border: 1px solid #b4a08b;
          position: absolute;
        }
        .floorListTop2 {
          width: 172px;
          height: 172;
          border-radius: 10px;
        }
      }
      .floorListCenter {
        display: flex;
        width: 172px;
        height: 40px;
        .floorListCenterImg {
          margin: 10px 2px 5px;
          width: 15px;
          height: 15px;
        }
        .floorListCenterTexte {
          font-size: 13px;
          margin-top: 8px;
          // font-weight: 400;
        }
      }
      .money {
        margin-top: 10px;
        width: 58px;
        height: 15px;
        border: 1px solid red;
        display: flex;
        align-items: center;
        border-radius: 10px;
        justify-content: center;
        .moneyImg {
          width: 10px;
          height: 10px;
          margin-left: 2px;
        }
        .moneyText {
          width: 50px;
          height: 15px;
          font-size: 10px;
        }
      }
      .hand {
        height: 30px;

        .hand1 {
          width: 24px;
          height: 13px;
          font-weight: 700;
          font-size: 13px;
          color: red;
        }
        .hand2 {
          font-weight: 700;
          font-size: 20px;
          color: red;
        }
        .hand3 {
          font-size: 14px;
          color: #999999;
          text-decoration: line-through;
        }
      }
      .floorListFoot {
        width: 65px;
        height: 19px;
        font-size: 11px;
        border: 1px solid red;
        background-color: red;
        border-radius: 30px;
        color: #f4f4f4;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 3px;
      }
    }
  }
}
</style>
